﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MvcEngine.Core.Base;
using MvcEngine.Mvc.UI;
using MvcEngine.Core.Validation;

namespace MvcEngine.Blog.Models
{
    public class OverviewPageContent : Entity
    {
        public OverviewPageContent()
        {

        }

        public OverviewPageContent(Entity entity)
            : base(entity)
        {

        }

        [RequiredFieldValidator("$RequiredValidator")]
        public int PostCount
        {
            get { return GetValue<int>("PostCount", 0); }
            set { Fields.SetValue("PostCount", value); }
        }

        public List<Guid> BlogIds
        {
            get
            {
                var ids = ((List<Guid>)Fields.GetValue("BlogIds"));
                if (ids == null)
                {
                    ids = new List<Guid>();
                    Fields.SetValue("BlogIds", ids);
                }
                return ids;
            }
            set { Fields.SetValue("BlogIds", value); }
        }

        public override string Xml { get; set; }
    }
}
